import { AnnotationEnum } from './AnnotationEnum';
import 'reflect-metadata';
import { TableStruct, TableStructCache } from '../db/TableStructCache';
import { ColumnType } from '../db/ColumnType';

const TAG = "CJDBUtil"

export const Ignore = (): PropertyDecorator => {
  return (target, primaryKey: string) => {

    Reflect.defineMetadata(ColumnType.IGNORE, true, target, primaryKey);
    // Reflect.defineMetadata(AnnotationEnum.TYPE, ColumnType.TEXT, target, primaryKey);

    // =======================

    // CJLogUtil.info(TAG, "constructor.arguments：" + JSON.stringify(target.constructor.arguments))
    // CJLogUtil.info(TAG, "table cache has：" + TableStructCache.maps.has(target.constructor.name))
    if (!TableStructCache.structMaps.has(target.constructor.name)) {
      TableStructCache.structMaps.set(target.constructor.name, [])
    }
    let caches: Array<TableStruct> = TableStructCache.structMaps.get(target.constructor.name)
    caches.push({
      name: primaryKey,
      // columnName: columnName,
      type: ColumnType.TEXT,
      propertyType: "object",
    })
    // CJLogUtil.info(TAG, "TableStructCache：" + JSON.stringify(TableStructCache.structMaps.get(target.constructor.name)))
  };
}